package lang


type InternPool struct {
	Items []*Interned
}

func (i *InternPool) Add(s *Interned) {
	i.Items = append(i.Items, s)
}

func (i *InternPool) Get(s *TStr) TObj {
	for _, v := range i.Items {
		if v.Equals(s) {
			return v
		}
	}
	return s
}

var IPool = &InternPool{Items: make([]*Interned, 0, 4)}

func intern(s string) TObj {
	k := newInterned(newTStr([]byte(s)))
	IPool.Add(k)
	return k
}
